/**
 * Description: 使用正则表达式把字符串"ABCDEFG"中的"CD"截取出来，再将"B"、"F"截取出来
 * Class Name:subject2
 * Date:2022/2/24 13:05
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第7章_Java基础类库.课后练习;

import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class subject2 {
    public static void main(String[] args) {
        String target_str = "ABCDEFG";
        Pattern p = Pattern.compile("\\w*(B)\\w*(CD)\\w*(F)\\w*");
        Matcher m = p.matcher(target_str);
        if (m.find()){
            System.out.println(m.group(2));
            System.out.println(m.group(1));
            System.out.println(m.group(3));
        }
    }
}
